﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace VS.Web
{
    /// <summary>
    /// Summary description for DownloadFile
    /// </summary>
    public class DownloadFile : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "image/jpeg";
            context.Response.ContentType = "application/octet-stream";
            FileInfo f = new FileInfo(HttpContext.Current.Server.MapPath(context.Request.QueryString["file"]));
            context.Response.AddHeader("content-disposition", "attachment;filename=" + f.Name.Replace(" ", "_"));
            context.Response.TransmitFile(context.Request.QueryString["file"]);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}